var times = 0;
	
function select(id){
    alert(id);
    obj = document.getElementById(id).src;
    //name = obj.substring(obj.lastIndexOf("/") + 1);
    alert(name);
    if(name == "AvailableSeat.gif"){
        document.getElementById(id).src = "picture/SelectedSeat.gif";
    }else if(name == "picture/SelectedSeat.gif"){
        document.getElementById(id).src = "AvailableSeat.gif";
    }
}
	
// append row to the HTML table
function appendRow() {
    var tbl = document.getElementById('my_table'), // table reference
    row = tbl.insertRow(tbl.rows.length),      // append table row
    i;
    // insert table cells to the new row
    for (i = 0; i < tbl.rows[0].cells.length; i++) {
        if(i == 0){
            var label = "";
            if(tbl.rows.length % 26 < 2){
                label += String.fromCharCode((tbl.rows.length % 26) + 89);
            }else{
                label += String.fromCharCode((tbl.rows.length % 26) + 63);
            }
            createCell(row.insertCell(i), label, 'row');
        }else{
            var name = label + " " + '5';
            createCell2(row.insertCell(i), "AvailableSeat.gif", 20, 20 , "", 'row');
        }
    }
}
		
// append column to the HTML table
function appendColumn() {
    var tbl = document.getElementById('my_table'), // table reference
    i;
    // open loop for each row and append cell
    for (i = 0; i < tbl.rows.length; i++) {
        if(i == 0){
            createCell(tbl.rows[i].insertCell(tbl.rows[i].cells.length), (tbl.rows[i].cells.length - 1), 'col');
        }else{
            var name = 'stub';
            createCell2(tbl.rows[i].insertCell(tbl.rows[i].cells.length), "AvailableSeat.gif", 20, 20 , "", 'col');
        }
    }
}
		 
// create DIV element and append to the table cell
function createCell(cell, text, style) {
    var div = document.createElement('div'), // create DIV element
    txt = document.createTextNode(text); // create text node
    div.appendChild(txt);                    // append text node to the DIV
    div.setAttribute('class', style);        // set DIV class attribute
    div.setAttribute('className', style);    // set DIV class attribute for IE (?!) 
    cell.appendChild(div);                   // append DIV to the table cell
}
		
function testing(){
    alert('16');
}
		
// create DIV element and append to the table cell
function createCell2(cell, src, width, height, alt, style){
    var div = document.createElement('div'),
    img = document.createElement('img');
    img.src = src;
    img.width = 20;
    img.height = 20;
    img.alt = alt;
    img.id = "abc";
    img.onclick = "testing();";
    alert("<img id=\"" + img.id + "\" value=\"" + img.src + "\" onclick=\"" + img.onclick + "\"" + " width=\"" + img.width + " \" height=\"" + img.height + "\" alt=\"" + img.alt + "\" />");
    div.appendChild(img);                    // append text node to the DIV
    div.setAttribute('class', style);        // set DIV class attribute
    div.setAttribute('className', style);    // set DIV class attribute for IE (?!) 
    cell.appendChild(div);                   // append DIV to the table cell
}
		
// delete table rows with index greater then 0
function deleteRows() {
    var tbl = document.getElementById('my_table'), // table reference
    lastRow = tbl.rows.length - 1,             // set the last row index
    i;
    // delete rows with index greater then 0
    for (i = lastRow; i > 0; i--) {
        tbl.deleteRow(i);
    }
}
		
		
 
// delete table columns with index greater then 0
function deleteAColumns() {
    var tbl = document.getElementById('my_table'), // table reference
    lastCol = tbl.rows[0].cells.length - 1,    // set the last column index
    i, j;
    // delete cells with index greater then 0 (for each row)
    for (i = 0; i < tbl.rows.length; i++) {
        for (j = lastCol; j > 0; j--) {
            tbl.rows[i].deleteCell(j);
        }
    }
}


